package day25;

/**
 * @ClassName Soluton
 * @Description TODO
 * @Author clockTown
 * @Date 2021/6/3 19:17
 * @Version 1.0
 */
public class Solution2 {
    public ListNode middleNode(ListNode head) {

        int count = 0;
        ListNode iter = head;

        while (iter != null) {
            count ++;
            iter = iter.next;
        }

        iter = head;
        int k = 0;
        while (k < count / 2){
            iter = iter.next;
            k++;
        }

        return iter;
    }
}
